<?php
	
	class stat_shoporder_dayControl extends skymvc{
		public $sw=" k='shop' ";
		public function __construct(){
			
			parent::__construct();
			
		}
		
		public function onDefault(){
			$where= $this->sw." AND  shopid=".SHOPID;
			$start=get('per_page','i');
			$limit=20;
			$url=APPSHOP."?m=stat_shoporder_day";
			$option=array(
				"where"=>$where,
				"start"=>$start,
				"limit"=>$limit,
				"order"=>" id DESC",
			);
			$rscount=true;
			$data=M("stat_shoporder_day")->select($option,$rscount);
			$pagelist=$this->pagelist($rscount,$limit,$url);
			$this->smarty->assign(array(
				"list"=>$data,
				"rscount"=>$rscount,
				"pagelist"=>$pagelist
				
			));
			
			$this->smarty->display("stat_shoporder_day/index.html");
		}
		
		public function onChart(){
			$where= $this->sw." AND  shopid=".SHOPID;
			$start=get('per_page','i');
			$limit=30;
			$url=APPKOUDAI."?m=stat_shoporder_day";
			$option=array(
				"where"=>$where,
				"start"=>$start,
				"limit"=>$limit,
				"order"=>" id DESC",
			);
			$rscount=true;
			$data=M("stat_shoporder_day")->select($option,$rscount);
			$pagelist=$this->pagelist($rscount,$limit,$url);
			$labels="";
			$moneys="";
			if($data){
				
				foreach($data as $k=>$v){
					$labels .=($k==0)?('"'.substr($v['kday'],4,4).'"'):(',"'.substr($v['kday'],4,4).'"');
					$moneys .=($k==0)?$v['money']:(",".$v['money']);
				}
			}
			 
			$this->smarty->assign(array(
				"list"=>$data,
				"rscount"=>$rscount,
				"pagelist"=>$pagelist,
				"labels"=>$labels,
				"moneys"=>$moneys,
				
			));
			
			$this->smarty->display("stat_shoporder_day/chart.html");
		}
		
			
	}
	
	
?>